<?php
namespace app\admin\controller;

use app\common\model\ZhModules as ZhModulesModel;

/**
 * 活动控制器
 * Class Zhmodules
 * @package app\index\controller
 */
class Zhmodules extends Base
{
    /**
     * [all 获取所有活动]
     * @return mixed|string
     * @author [C。]
     */
    public function all()
    {
        $model = new ZhModulesModel();
        try{
            $data = $model->getAllData(['status'=>1]);
        }catch (\Exception $e) {
            return admin_json(-1,'获取失败'.$e->getMessage());
        }
        return admin_json(1,'获取成功',$data);
    }
    /**
     * [postAdd  添加]
     * @return mixed|string
     * @author [C。]
     */
    public function add()
    {
        $param = input('param.');
        $model = new ZhModulesModel();
        try{
            $model->addData1($param);
        }catch (\Exception $e) {
            return admin_json(-1,'添加失败'.$e->getMessage());
        }
        return admin_json(1,'添加成功');
    }
    /**
     * [postEdit  修改]
     * @return mixed|string
     * @author [C。]
     */
    public function edit()
    {
        $param = input('param.');
        $model = new ZhModulesModel();
        try{
            $model->editData1($param);
        }catch (\Exception $e) {
            return admin_json(-1,'修改失败'.$e->getMessage());
        }
        return admin_json(1,'修改成功');
    }
    /**
     * [getDel 删除]
     * @return mixed|string
     * @author [C。]
     */
    public function del()
    {
        $param = input('param.');
        $model = new ZhModulesModel();
        $user = $this->user;
        try{
            $model->editData1(['status' => 2,'tid' => $param['tid']]);
        }catch (\Exception $e) {
            return admin_json(-1,'删除失败'.$e->getMessage());
        }
        return admin_json(1,'删除成功');
    }
}